import { Injectable } from '@angular/core';
import { Global } from 'src/global';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { P_Comment } from './comment';
import { Pokemon } from './pockemon';


@Injectable({
  providedIn: 'root'
})
export class PokemonService {

  constructor(private http: HttpClient) { }
  url =Global.commonURL+"/get_pokemon"
  getpokemon(id:string):Observable<any>{
    return this.http.get(this.url+"?id="+id)
  }
  getcommentArr(id:string):Observable<any>{
    return this.http.get(Global.commonURL+"/get_commentArr?id="+id)
  }
  submitComment(comment:P_Comment):Observable<any>{
    return this.http.post(Global.commonURL+"/add_comment",{'comment':comment})
  }
  deleteComment(cid:string):Observable<any>{
    return this.http.post(Global.commonURL+"/del_comment",{'id':cid})
  }
  likeComment(cid: string,username:string):Observable<any>{
    return this.http.post(Global.commonURL+"/like_comment",{'id':cid,'username':username})
  }
  dislikeComment(cid: string,username:string):Observable<any>{
    return this.http.post(Global.commonURL+"/dislike_comment",{'id':cid,'username':username})
  }
  collection(pid: Pokemon,username:string):Observable<any>{
    return this.http.post(Global.commonURL+"/collection",{'id':pid,'username':username})

  }
  discollection(pid: Pokemon,username:string):Observable<any>{
    
    return this.http.post(Global.commonURL+"/discollection",{'id':pid,'username':username})
  }
  get_user(username: string):Observable<any>{
    
    return this.http.post(Global.commonURL+"/get_user",{'username':username})
  }
}
